<?php
/*
// OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
// all the essential functionalities required for any enterprise.
// Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com

// OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
// the GNU General Public License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.

// OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along with this program;
// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA  02110-1301, USA
*/

require_once ROOT_PATH . '/lib/confs/Conf.php';
require_once ROOT_PATH . '/lib/dao/DMLFunctions.php';
require_once ROOT_PATH . '/lib/dao/SQLQBuilder.php';
require_once ROOT_PATH . '/lib/common/CommonFunctions.php';

class EmpBasSalary {

	var $tableName = 'hs_hr_emp_basicsalary';

	var $empId;
	var $empSalGrdCode;
	var $empCurrCode;
	var $empBasSal;
	var $empoldetxtBasSal;
	var $empLastBasSal;
	var $empTempAllo;
	var $empNightAllo;
	var $empOtherAllo;
	var $empLoseWorkIns;
	var $empMedicalIns;
	var $empEndowIns;
	var $empMaterIns;
	var $empHouseFund;
	var $empOtherAlloRemark;
	var $empEffDate;
	var $empLongevityPay; //年功
	var $empEduPay; //学历加薪
	var $empAdmPay; //管理者课加薪
	var $empJobPay; //职位加薪
	var $empDaySalId; //对应日薪标准ID

	var $arrayDispList;
	var $singleField;

	var $payPeriod;

	function EmpBasSalary() {

	}

	function setEmpId($empId) {

	$this->empId=$empId;
	}

	function setEmpSalGrdCode($empSalGrdCode) {

	$this->empSalGrdCode=$empSalGrdCode;
	}

	function setEmpCurrCode($empCurrCode) {

	$this->empCurrCode=$empCurrCode;
	}

	function setEmpBasSal($empBasSal) {

	$this->empBasSal=$empBasSal;
	}
	
	function setEmpoldetxtBasSal($empoldetxtBasSal) {

	$this->empoldetxtBasSal=$empoldetxtBasSal;
	}
	
	function setEmpDaySalId($empDaySalId) {

	$this->empDaySalId=$empDaySalId;
	}

	function getEmpId() {

	return $this->empId;
	}

	function getEmpSalGrdCode() {

	return $this->empSalGrdCode;
	}

	function getEmpCurrCode() {

	return $this->empCurrCode;
	}

	function getEmpBasSal() {

	return $this->empBasSal;
	}
	
	function getEmpoldetxtBasSal() {

	return $this->empoldetxtBasSal;
	}

	function getPayPeriod() {
		return $this->payPeriod;
	}

	function setPayPeriod($payPeriod) {
		$this->payPeriod = $payPeriod;
	}

	function getEmpLastBasSal() {
		return $this->empLastBasSal;
	}

	function getEmpDaySalId() {
		return $this->empDaySalId;
	}

	function setEmpLastBasSal($empLastBasSal) {
		$this->empLastBasSal = $empLastBasSal;
	}

	function getEmpTempAllo() {
		return $this->empTempAllo;
	}

	function setEmpTempAllo($empTempAllo) {
		$this->empTempAllo = $empTempAllo;
	}

	function getEmpNightAllo() {
		return $this->empNightAllo;
	}

	function setEmpNightAllo($empNightAllo) {
		$this->empNightAllo = $empNightAllo;
	}

	function getEmpOtherAllo() {
		return $this->empOtherAllo;
	}

	function setEmpOtherAllo($empOtherAllo) {
		$this->empOtherAllo = $empOtherAllo;
	}

	function getEmpOtherAlloRemark() {
		return $this->empOtherAlloRemark;
	}

	function setEmpOtherAlloRemark($empOtherAlloRemark) {
		$this->empOtherAlloRemark = $empOtherAlloRemark;
	}

	function getEmpLoseWorkIns() {
		return $this->empLoseWorkIns;
	}

	function setEmpLoseWorkIns($empLoseWorkIns) {
		$this->empLoseWorkIns = $empLoseWorkIns;
	}

	function getEmpMedicalIns() {
		return $this->empMedicalIns;
	}

	function setEmpMedicalIns($empMedicalIns) {
		$this->empMedicalIns = $empMedicalIns;
	}

	function getEmpEndowIns() {
		return $this->empEndowIns;
	}

	function setEmpEndowIns($empEndowIns) {
		$this->empEndowIns = $empEndowIns;
	}

	function getEmpMaterIns() {
		return $this->empMaterIns;
	}

	function setEmpMaterIns($empMaterIns) {
		$this->empMaterIns = $empMaterIns;
	}

	function getEmpHouseFund() {
		return $this->empHouseFund;
	}

	function setEmpHouseFund($empHouseFund) {
		$this->empHouseFund = $empHouseFund;
	}

	function getEmpEffDate() {
		return $this->empEffDate;
	}

	function setEmpEffDate($empEffDate) {
		if($empEffDate=="YYYY-mm-DD" || !$empEffDate)
			$empEffDate = @date("Y-m-d",time());
		$this->empEffDate = $empEffDate;
	}

	function getEmpLongevityPay() {
		return $this->empLongevityPay;
	}

	function setEmpLongevityPay($empLongevityPay) {
		$this->empLongevityPay = $empLongevityPay;
	}

	function getEmpEduPay() {
		return $this->empEduPay;
	}

	function setEmpEduPay($empEduPay) {
		$this->empEduPay = $empEduPay;
	}

	function getEmpAdmPay() {
		return $this->empAdmPay;
	}

	function setEmpAdmPay($empAdmPay) {
		$this->empAdmPay = $empAdmPay;
	}

	function getEmpJobPay() {
		return $this->empJobPay;
	}

	function setEmpJobPay($empJobPay) {
		$this->empJobPay = $empJobPay;
	}
	
	////


	function getListofEmpBasSal($page,$str,$mode) {

		$tableName = 'hs_hr_emp_basicsalary';

		$sql_builder = new SQLQBuilder();

		$sql_builder->table_name = $tableName;
		$sql_builder->flg_select = 'true';
		$sql_builder->field = 'EMP_NUMBER';

		$sqlQString = $sql_builder->selectEmployee($page,$str,$mode);

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		$i=0;

		 while ($line = mysql_fetch_array($message2, MYSQL_NUM)) {

	    	$arrayDispList[$i][0] = $line[0];
	    	$arrayDispList[$i][1] = $line[1];
	    	$i++;

	     }

	     if (isset($arrayDispList)) {

			return $arrayDispList;

		} else {

			$arrayDispList = '';
			return $arrayDispList;

		}
	}

	function countEmpBasSal($str,$mode) {

		$tableName = 'hs_hr_emp_basicsalary';

		$sql_builder = new SQLQBuilder();

		$sql_builder->table_name = $tableName;
		$sql_builder->flg_select = 'true';
		$sql_builder->field = 'EMP_NUMBER';

		$sqlQString = $sql_builder->countEmployee($str,$mode);

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		$line = mysql_fetch_array($message2, MYSQL_NUM);

	    	return $line[0];
	}

	function delEmpBasSal($arrList) {

		$tableName = 'hs_hr_emp_basicsalary';
		$arrFieldList[0] = 'EMP_NUMBER';
		//$arrFieldList[1] = 'SAL_GRD_CODE';
		//$arrFieldList[2] = 'CURRENCY_ID';

		$sql_builder = new SQLQBuilder();

		$sql_builder->table_name = $tableName;
		$sql_builder->flg_delete = 'true';
		$sql_builder->arr_delete = $arrFieldList;

		$sqlQString = $sql_builder->deleteRecord($arrList);

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

	}
	
	function updateEmpBasSalByDaySalId($daysal_id) {

        $arrRecordsList[0] = "'" . $daysal_id . "'";
        $arrRecordsList[1] = 0;

        $tableName = 'hs_hr_emp_basicsalary';

        $arrFieldList[0] = 'DAYSAL_ID';
        $arrFieldList[1] = 'DAYSAL_ID';

        $sql_builder = new SQLQBuilder();

        $sql_builder->table_name = $tableName;
        $sql_builder->flg_update = 'true';
        $sql_builder->arr_update = $arrFieldList;
        $sql_builder->arr_updateRecList = $arrRecordsList;

        $sqlQString = $sql_builder->addUpdateRecord1();

        $dbConnection = new DMLFunctions();
        $message2 = $dbConnection->executeQuery($sqlQString); //Calling the addData() function

        return $message2;
    }

	function addEmpBasSal() {

		$this->getEmpId();
		$arrFieldList[0] = "'". $this->getEmpId() . "'";
		$arrFieldList[1] = "'". $this->getEmpSalGrdCode() . "'";
		$arrFieldList[2] = "'". $this->getEmpCurrCode() . "'";
		$arrFieldList[3] = "'". $this->getEmpBasSal() . "'";
		$arrFieldList[4] = "'". $this->getEmpLastBasSal() . "'";
		$arrFieldList[5] = "'". $this->getEmpTempAllo() . "'";
		$arrFieldList[6] = "'". $this->getEmpNightAllo() . "'";
		$arrFieldList[7] = "'". $this->getEmpOtherAllo() . "'";
		$arrFieldList[13] = "'". $this->getEmpOtherAlloRemark() . "'";
		$arrFieldList[8] = "'". $this->getEmpLoseWorkIns() . "'";
		$arrFieldList[9] = "'". $this->getEmpMedicalIns() . "'";
		$arrFieldList[10] = "'". $this->getEmpEndowIns() . "'";
		$arrFieldList[11] = "'". $this->getEmpMaterIns() . "'";
		$arrFieldList[12] = "'". $this->getEmpHouseFund() . "'";
		$arrFieldList[14] = "'". $this->getEmpEffDate() . "'";
		$arrFieldList[15] = "'". $this->getEmpLongevityPay() . "'";
		$arrFieldList[16] = "'". $this->getEmpEduPay() . "'";
		$arrFieldList[17] = "'". $this->getEmpAdmPay() . "'";
		$arrFieldList[18] = "'". $this->getEmpJobPay() . "'";
		$arrFieldList[19] = "'". $this->getEmpDaySalId() . "'";
		//$arrFieldList[4] = empty($this->payPeriod) ? "null" : "'". $this->payPeriod . "'";
		/* 记录调薪 by jingking start */
		require_once ROOT_PATH . '/lib/models/hrfunct/AdministraMana.php';
		$SalaryAdjArr['EmpId'] = $this->getEmpId();
		$SalaryAdjArr['MoldId'] = 1;
		$SalaryAdjArr['SalaryBefore'] = 0;
		$SalaryAdjArr['SalaryAfter'] = $this->getEmpBasSal();
		$SalaryAdjArr['Content'] = "添加工资";
		$AdministraMana = new AdministraMana();
		$AdministraMana->SaveSalaryAdjustments($SalaryAdjArr);
		/* 记录调薪 end */
		$fields[0] = 'EMP_NUMBER';
		$fields[1] = 'SAL_GRD_CODE';
		$fields[2] = 'CURRENCY_ID';
		$fields[3] = 'EBSAL_BASIC_SALARY';
		$fields[4] = 'LAST_BASIC_SALARY';
		$fields[5] = 'HIGHT_TEMP_ALLOWANCE';
		$fields[6] = 'NIGHT_WORK_ALLOWANCE';
		$fields[7] = 'OTHER_ALLOWANCE';
		$fields[8] = 'LOSEWORK_INSURANCE';
		$fields[9] = 'MEDICAL_INSURANCE';
		$fields[10] = 'ENDOWMENT_INSURANCE';
		$fields[11] = 'MATERNITY_INSURANCE';
		$fields[12] = 'HOUSING_FUND';
		$fields[13] = 'OTHER_ALLOWANCE_REMARK';
		$fields[14] = 'EFFECTIVE_DATE';
		$fields[15] = 'LONGEVITY_PAY';
		$fields[16] = 'EDU_PAY';
		$fields[17] = 'ADM_PAY';
		$fields[18] = 'JOB_PAY';
		$fields[19] = 'DAYSAL_ID';
		//$fields[4] = 'PAYPERIOD_CODE';

		$tableName = 'hs_hr_emp_basicsalary';

		$sql_builder = new SQLQBuilder();

		$sql_builder->table_name = $tableName;
		$sql_builder->flg_insert = 'true';
		$sql_builder->arr_insert = $arrFieldList;
		$sql_builder->arr_insertfield = $fields;

		$sqlQString = $sql_builder->addNewRecordFeature2();

		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		 return $message2;


	}

	function updateEmpBasSal($object =  null) {
		
		$fields[0] = 'emp_number';
		$fields[1] = 'sal_grd_code';
		$fields[2] = 'currency_id';
		$fields[3] = 'ebsal_basic_salary';
		$fields[4] = 'last_basic_salary';
		$fields[5] = 'hight_temp_allowance';
		$fields[6] = 'night_work_allowance';
		$fields[7] = 'other_allowance';
		$fields[8] = 'losework_insurance';
		$fields[9] = 'medical_insurance';
		$fields[10] = 'endowment_insurance';
		$fields[11] = 'maternity_insurance';
		$fields[12] = 'housing_fund';
		$fields[13] = 'other_allowance_remark';
		$fields[14] = 'effective_date';
		$fields[15] = 'longevity_pay';
		$fields[16] = 'edu_pay';
		$fields[17] = 'adm_pay';
		$fields[18] = 'job_pay';
		$fields[19] = 'daysal_id';
				
		$tableName = 'hs_hr_emp_basicsalary';
		$sql_builder = new SQLQBuilder();
		$SalaryAdjArr = array();
		$dbConnection = new DMLFunctions();
		
		if(is_array($object)){

			$newObject = $object['new'];
			$values[0] = $newObject->getEmpId();
			$values[1] = "'". $newObject->getEmpSalGrdCode() . "'";
			$values[2] = "'". $newObject->getEmpCurrCode() . "'";
			$values[3] = "'". $newObject->getEmpBasSal() . "'";
			$values[4] = "'". $newObject->getEmpLastBasSal() . "'";
			$values[5] = "'". $newObject->getEmpTempAllo() . "'";
			$values[6] = "'". $newObject->getEmpNightAllo() . "'";
			$values[7] = "'". $newObject->getEmpOtherAllo() . "'";
			$values[8] = "'". $newObject->getEmpLoseWorkIns() . "'";
			$values[9] = "'". $newObject->getEmpMedicalIns() . "'";
			$values[10] = "'". $newObject->getEmpEndowIns() . "'";
			$values[11] = "'". $newObject->getEmpMaterIns() . "'";
			$values[12] = "'". $newObject->getEmpHouseFund() . "'";
			$values[13] = "'". $newObject->getEmpOtherAlloRemark() . "'";
			$values[14] = "'". $newObject->getEmpEffDate() . "'";
			$values[15] = "'". $newObject->getEmpLongevityPay() . "'";
			$values[16] = "'". $newObject->getEmpEduPay() . "'";
			$values[17] = "'". $newObject->getEmpAdmPay() . "'";
			$values[18] = "'". $newObject->getEmpJobPay() . "'";
			$values[19] = "'". $newObject->getEmpDaySalId() . "'";
			//$values[4] = empty($newObject->payPeriod) ? "null" :$newObject->payPeriod;
			//print_r($values);exit();
			/* 记录调薪 by jingking start */
			if($newObject->getEmpoldetxtBasSal() != $newObject->getEmpBasSal()) {
				$SalaryAdjArr['EmpoldetxtBasSal'] = $newObject->getEmpoldetxtBasSal();
				$SalaryAdjArr['EmpId'] = $newObject->getEmpId();
				$SalaryAdjArr['MoldId'] = 1;
				$SalaryAdjArr['SalaryBefore'] = $newObject->getEmpLastBasSal();
				$SalaryAdjArr['SalaryAfter'] = $newObject->getEmpBasSal();
			} else {
				$SalaryAdjArr['EmpoldetxtBasSal'] = "";
				$SalaryAdjArr['SalaryAfter'] = "";
			}
			/* 记录调薪 end */
			$selsql = "select emp_number from hs_hr_emp_basicsalary where emp_number=".$values[0];
			$query = $dbConnection -> executeQuery($selsql); //Calling the addData() function
			$row = mysql_affected_rows();

			if($row>0){
				//$oldObject = $object['old'];
				//$updateCondition[] = "SAL_GRD_CODE = '".$oldObject->getEmpSalGrdCode()."'";
				//$updateCondition[] = "CURRENCY_ID = '".$oldObject->getEmpCurrCode()."'";
				$updateCondition[] = "emp_number = '".$newObject->getEmpId()."'";
				$sqlQString = $sql_builder->simpleUpdate($tableName,$fields,$values,$updateCondition,false);
				
			}else {
				$sql_builder->table_name = $tableName;
				$sql_builder->flg_insert = 'true';
				$sql_builder->arr_insert = $values;
				$sql_builder->arr_insertfield = $fields;

				$sqlQString = $sql_builder->addNewRecordFeature2();
			}

		}else{

			$sql_builder->table_name = $tableName;

			$arrRecordsList[0] = "'". $this->getEmpId() . "'";
			$arrRecordsList[1] = "'". $this->getEmpSalGrdCode() . "'";
			$arrRecordsList[2] = "'". $this->getEmpCurrCode() . "'";
			$arrRecordsList[3] = "'". $this->getEmpBasSal() . "'";
			$arrRecordsList[4] = "'". $this->getEmpLastBasSal() . "'";
			$arrRecordsList[5] = "'". $this->getEmpTempAllo() . "'";
			$arrRecordsList[6] = "'". $this->getEmpNightAllo() . "'";
			$arrRecordsList[7] = "'". $this->getEmpOtherAllo() . "'";
			$arrRecordsList[13] = "'". $this->getEmpOtherAlloRemark() . "'";
			$arrRecordsList[8] = "'". $this->getEmpLoseWorkIns() . "'";
			$arrRecordsList[9] = "'". $this->getEmpMedicalIns() . "'";
			$arrRecordsList[10] = "'". $this->getEmpEndowIns() . "'";
			$arrRecordsList[11] = "'". $this->getEmpMaterIns() . "'";
			$arrRecordsList[12] = "'". $this->getEmpHouseFund() . "'";
			$arrRecordsList[14] = "'". $this->getEmpEffDate() . "'";
			$arrRecordsList[15] = "'". $this->getEmpLongevityPay() . "'";
			$arrRecordsList[16] = "'". $this->getEmpEduPay() . "'";
			$arrRecordsList[17] = "'". $this->getEmpAdmPay() . "'";
			$arrRecordsList[18] = "'". $this->getEmpJobPay() . "'";
			$arrRecordsList[19] = "'". $this->getEmpDaySalId() . "'";
			//$arrRecordsList[4] = empty($this->payPeriod) ? "null" : "'". $this->payPeriod . "'";
			/* 记录调薪 by jingking start */
			if($this->getEmpoldetxtBasSal() != $this->getEmpBasSal()) {
				$SalaryAdjArr['EmpoldetxtBasSal'] = $this->getEmpoldetxtBasSal();
				$SalaryAdjArr['EmpId'] = $this->getEmpId();
				$SalaryAdjArr['MoldId'] = 1;
				$SalaryAdjArr['SalaryBefore'] = $this->getEmpLastBasSal();
				$SalaryAdjArr['SalaryAfter'] = $this->getEmpBasSal();
			} else {
				$SalaryAdjArr['EmpoldetxtBasSal'] = "";
				$SalaryAdjArr['SalaryAfter'] = "";
			}
			/* 记录调薪 end */
			$selsql = "select emp_number from hs_hr_emp_basicsalary where emp_number=".$this->getEmpId();
			$query = $dbConnection -> executeQuery($selsql); //Calling the addData() function
			$row = mysql_affected_rows();
			if($row>0) {
				$sql_builder->table_name = $tableName;
				$sql_builder->flg_update = 'true';
				$sql_builder->arr_update = $fields;
				$sql_builder->arr_updateRecList = $arrRecordsList;

				$sqlQString = $sql_builder->addUpdateRecord1(2);
			}else {
				$sql_builder->table_name = $tableName;
				$sql_builder->flg_insert = 'true';
				$sql_builder->arr_insert = $values;
				$sql_builder->arr_insertfield = $fields;

				$sqlQString = $sql_builder->addNewRecordFeature2();
			}
		}
		/* 记录调薪 by jingking start */
		require_once ROOT_PATH . '/lib/models/hrfunct/AdministraMana.php';
		if(($SalaryAdjArr['EmpoldetxtBasSal'] != $SalaryAdjArr['SalaryAfter']) && isset($SalaryAdjArr['SalaryAfter'])) {
			$SalaryAdjArr['Content'] = "调整工资";
			$AdministraMana = new AdministraMana();
			$AdministraMana->SaveSalaryAdjustments($SalaryAdjArr);
		}
		/* 记录调薪 end */
		//$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		return $message2;
	}


	function filterEmpBasSal($getID) {

		$this->getID = $getID;
		$tableName = 'hs_hr_emp_basicsalary';
		$arrFieldList[0] = 'EMP_NUMBER';
		$arrFieldList[1] = 'SAL_GRD_CODE';
		$arrFieldList[2] = 'CURRENCY_ID';
		$arrFieldList[3] = 'EBSAL_BASIC_SALARY';
		$arrFieldList[4] = 'LAST_BASIC_SALARY';
		$arrFieldList[5] = 'HIGHT_TEMP_ALLOWANCE';
		$arrFieldList[6] = 'NIGHT_WORK_ALLOWANCE';
		$arrFieldList[7] = 'OTHER_ALLOWANCE';
		$arrFieldList[8] = 'LOSEWORK_INSURANCE';
		$arrFieldList[9] = 'MEDICAL_INSURANCE';
		$arrFieldList[10] = 'ENDOWMENT_INSURANCE';
		$arrFieldList[11] = 'MATERNITY_INSURANCE';
		$arrFieldList[12] = 'HOUSING_FUND';
		$arrFieldList[13] = 'OTHER_ALLOWANCE_REMARK';
		$arrFieldList[14] = 'EFFECTIVE_DATE';
		$arrFieldList[15] = 'LONGEVITY_PAY';
		$arrFieldList[16] = 'EDU_PAY';
		$arrFieldList[17] = 'ADM_PAY';
		$arrFieldList[18] = 'JOB_PAY';
		$arrFieldList[19] = 'DAYSAL_ID';
		//$arrFieldList[4] = 'PAYPERIOD_CODE';

		$sql_builder = new SQLQBuilder();

		$sql_builder->table_name = $tableName;
		$sql_builder->flg_select = 'true';
		$sql_builder->arr_select = $arrFieldList;

		$sqlQString = $sql_builder->selectOneRecordFiltered($this->getID);
		$sqlQString .= " limit 1";

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function
		$line = mysql_fetch_array($message2);
		$arrayDispList = array();
		if($line && is_array($line)) $arrayDispList = $line;
		
		return $arrayDispList;

		//$i=0;

		 /*while ($line = mysql_fetch_array($message2, MYSQL_NUM)) {

			for($c=0;count($arrFieldList)>$c;$c++)
			   $arrayDispList[$i][$c] = $line[$c];

	    	$i++;

	     }*/

	     /*if (isset($arrayDispList)) {

			return $arrayDispList;

		} else {

			$arrayDispList[] = array();
			return $arrayDispList;

		}*/

	}

	function getEmpSalGrade($empID) {
		$tableName = 'hs_hr_emp_basicsalary';
		$arrFieldList[0] = 'SAL_GRD_CODE';
		$selectCondition[0] = "`EMP_NUMBER` = '". $empID . "'";
		$sql_builder = new SQLQBuilder();

		$sqlQString = $sql_builder->simpleSelect($tableName, $arrFieldList, $selectCondition, $arrFieldList[0], 'ASC');

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		if(isset($message2)){
			while ($row = mysql_fetch_assoc($message2)) {
				if(isset($row['SAL_GRD_CODE'])){
					return $row['SAL_GRD_CODE'];
				}
			}
		}
	}

	function getAssEmpBasSal($getID) {

		$this->getID = $getID;
		$tableName = 'hs_hr_emp_basicsalary';
		$arrFieldList[0] = 'EMP_NUMBER';
		$arrFieldList[1] = 'SAL_GRD_CODE';
		$arrFieldList[2] = 'CURRENCY_ID';
		$arrFieldList[3] = 'EBSAL_BASIC_SALARY';
		$arrFieldList[4] = 'LAST_BASIC_SALARY';
		$arrFieldList[5] = 'HIGHT_TEMP_ALLOWANCE';
		$arrFieldList[6] = 'NIGHT_WORK_ALLOWANCE';
		$arrFieldList[7] = 'LOSEWORK_INSURANCE';
		$arrFieldList[8] = 'MEDICAL_INSURANCE';
		$arrFieldList[9] = 'ENDOWMENT_INSURANCE';
		$arrFieldList[10] = 'MATERNITY_INSURANCE';
		$arrFieldList[11] = 'HOUSING_FUND';
		$arrFieldList[12] = 'OTHER_ALLOWANCE_REMARK';
		$arrFieldList[13] = 'EFFECTIVE_DATE';
		$arrFieldList[14] = 'LONGEVITY_PAY';
		$arrFieldList[15] = 'EDU_PAY';
		$arrFieldList[16] = 'ADM_PAY';
		$arrFieldList[17] = 'JOB_PAY';
		$arrFieldList[18] = 'DAYSAL_ID';
		//$arrFieldList[4] = 'PAYPERIOD_CODE';

		$sql_builder = new SQLQBuilder();

		$sql_builder->table_name = $tableName;
		$sql_builder->flg_select = 'true';
		$sql_builder->arr_select = $arrFieldList;

		$sqlQString = $sql_builder->selectOneRecordFiltered($this->getID);

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		$i=0;

		 while ($line = mysql_fetch_array($message2, MYSQL_NUM)) {

			for($c=0;count($arrFieldList)>$c;$c++)
			   $arrayDispList[$i][$c] = $line[$c];

	    	$i++;

	     }

	     if (isset($arrayDispList)) {

			return $arrayDispList;

		} else {

			$arrayDispList = '';
			return $arrayDispList;

		}

	}

	function getCurrCodes($salGrd) {

		$sqlQString = "SELECT b.CURRENCY_NAME, a.* FROM HS_PR_SALARY_CURRENCY_DETAIL a, HS_HR_CURRENCY_TYPE b WHERE a.CURRENCY_ID = b.CURRENCY_ID AND a.SAL_GRD_CODE = '" . $salGrd . "'";
		$sqlQString = strtolower($sqlQString);

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();
		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		$i=0;

		 while ($line = mysql_fetch_array($message2, MYSQL_NUM)) {

	    	$arrayDispList[$i][0] = $line[0];
	    	$arrayDispList[$i][1] = $line[1];
	    	$arrayDispList[$i][2] = $line[2];
	    	$arrayDispList[$i][3] = $line[3];
	    	$arrayDispList[$i][4] = $line[4];
	    	$arrayDispList[$i][5] = $line[5];
	    	$i++;

	     }

	     if (isset($arrayDispList)) {

			return $arrayDispList;

		} else {

			$arrayDispList = '';
			return $arrayDispList;

		}
	}

	function getUnAssCurrCodes($salGrd,$eno) {

		$sqlQString = "SELECT b.CURRENCY_NAME, a.* FROM HS_PR_SALARY_CURRENCY_DETAIL a, HS_HR_CURRENCY_TYPE b WHERE a.CURRENCY_ID NOT IN (SELECT CURRENCY_ID FROM hs_hr_emp_basicsalary WHERE SAL_GRD_CODE = '" . $salGrd . "' AND EMP_NUMBER = '" .$eno. "') AND a.CURRENCY_ID = b.CURRENCY_ID AND a.SAL_GRD_CODE = '" . $salGrd . "'";
		$sqlQString = strtolower($sqlQString);

		//echo $sqlQString;
		$dbConnection = new DMLFunctions();

		$message2 = $dbConnection -> executeQuery($sqlQString); //Calling the addData() function

		$i=0;
		 while ($line = mysql_fetch_array($message2, MYSQL_NUM)) {

	    	$arrayDispList[$i][0] = $line[0];
	    	$arrayDispList[$i][1] = $line[1];
	    	$arrayDispList[$i][2] = $line[2];
	    	$arrayDispList[$i][3] = $line[3];
	    	$arrayDispList[$i][4] = $line[4];
	    	$arrayDispList[$i][5] = $line[5];
	    	$i++;
	     }

	     if (isset($arrayDispList)) {

			return $arrayDispList;

		} else {

			$arrayDispList = '';
			return $arrayDispList;

		}
	}


}

?>
